% This subroutine calculates between-sector wage gaps.
%
% Used in the paper "Land Insecurity and Mobility Frictions," by Tasso
% Adamopoulos, Loren Brandt, Chaoran Chen, Diego Restuccia, and Xiaoyun
% Wei, prepared for publication at the Quarterly Journal of Economics.
%
% Last modified: March 3, 2024

inc_diff_uo = sum(sum(log(ind_h*wu).*(dummy_urban+dummy_pt_u)))...
    /(sum(sum(dummy_urban+dummy_pt_u))+eps) - ...
    sum(log(farm_y*p+eps).*(1-hh_migration))/(sum(1-hh_migration)+eps);


inc_diff_ur = sum(sum(log(ind_h*wu).*(dummy_urban+dummy_pt_u)))...
    /(sum(sum(dummy_urban+dummy_pt_u))+eps) - ...
    sum(sum(log(ind_h*wr).*(dummy_rural+dummy_pt_r)))...
    /(sum(sum(dummy_rural+dummy_pt_r))+eps);

inc_diff_ro = sum(sum(log(ind_h*wr).*(dummy_rural+dummy_pt_r)))...
    /(sum(sum(dummy_rural+dummy_pt_r))+eps) - ...
    sum(log(farm_y*p+eps).*(1-hh_migration))/(sum(1-hh_migration)+eps);